package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xmy.cultivate.entity.*;
import com.xmy.cultivate.entity.views.PersonManage;
import com.xmy.cultivate.entity.views.ResDepartment;
import com.xmy.cultivate.enums.StatusStaffEnum;
import com.xmy.cultivate.service.*;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.PageResult;
import com.xmy.cultivate.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 人事管理
 */
@RestController
@RequestMapping("/api/person")
@Scope("prototype")
public class PersonController extends BaseController{

    @Autowired
    IStaffService iStaffService;

    @Autowired
    IStaffStationChangeService iStaffStationChangeService;

    @Autowired
    IStaffStatusChangeService iStaffStatusChangeService;

    @Autowired
    IOrganizationService iOrganizationService;

    @Autowired
    IQuarterService iQuarterService;

    @Autowired
    IDictService iDictService;

    @Autowired
    IStationService iStationService;

    @Autowired
    IAdminService iAdminService;

    @Autowired
    IRoleAdminService iRoleAdminService;

    @Autowired
    IOrganizationStaffService iOrganizationStaffService;

    @PostMapping("/addStataff")
    @ApiOperation("入职-添加员工表信息")
    public Result addStataff(@RequestBody Staff staff){
        iStaffService.save(staff);
        return new Result(Code.OK,"","成功");
    }

    @PostMapping("/editStataff")
    @ApiOperation("入职-修改员工表信息")
    public Result editStataff(@RequestBody Staff staff){
        if (staff.getId() == null) {
            return new Result(Code.ERROR, "", "员工表id不能为空");
        }
        Staff byId = iStaffService.getById(staff.getId());
        boolean b = iStaffService.updateById(staff);
        if (b) {
            return new Result(Code.OK, "", "修改员工表信息成功");
        } else {
            return new Result(Code.ERROR, "", "修改员工表信息失败");
        }
    }

    /**
     * 获取员工列表
//     * @param pageNum
//     * @param pageSize
//     * @param schoolId
     * @return
     */
    @GetMapping("/staffList")
    @ApiOperation("入职-获取员工列表")
    public Result staffList(@RequestParam Map<String,Object> reMap, @RequestParam(required = false) String[] statusArr, @RequestParam(required = false) String[] justType){
        int pageNum = StringUtils.isEmpty((CharSequence) reMap.get("pageNum")) ? 1 : Integer.parseInt((String) reMap.get("pageNum"));
        int pageSize = StringUtils.isEmpty((CharSequence) reMap.get("pageSize")) ? 10 : Integer.parseInt((String) reMap.get("pageSize"));
        IPage<Staff> page = new Page<>(pageNum, pageSize);

        String schoolId = reMap.get("schoolId") != null && !reMap.get("schoolId").toString().isEmpty()?reMap.get("schoolId").toString():null;
        String stationId = reMap.get("stationId") != null && !reMap.get("stationId").toString().isEmpty()?reMap.get("stationId").toString():null;
        String entryDate = reMap.get("entryDate") != null && !reMap.get("entryDate").toString().isEmpty()?reMap.get("entryDate").toString():null;
        String staffType = reMap.get("staffType") != null && !reMap.get("staffType").toString().isEmpty()?reMap.get("staffType").toString():null;
//        String justType = reMap.get("justType") != null && !reMap.get("justType").toString().isEmpty()?reMap.get("justType").toString():null;
        String yearPart = reMap.get("yearPart") != null && !reMap.get("yearPart").toString().isEmpty()?reMap.get("yearPart").toString():null;
        String quarterNum = reMap.get("quarterNum") != null && !reMap.get("quarterNum").toString().isEmpty()?reMap.get("quarterNum").toString():null;
//        String statusArr = reMap.get("statusArr") != null && !reMap.get("statusArr").toString().isEmpty()?reMap.get("statusArr").toString():null;
        String name = reMap.get("name") != null && !reMap.get("name").toString().isEmpty()?reMap.get("name").toString():null;
        String serve = reMap.get("serve") != null && !reMap.get("serve").toString().isEmpty()?reMap.get("serve").toString():null;

        QueryWrapper<Staff> staffQuarter = new QueryWrapper<>();
        staffQuarter.eq(StringUtils.isNotBlank(schoolId),"school_id",schoolId);
        staffQuarter.eq(StringUtils.isNotBlank(stationId),"station_id",stationId);
        staffQuarter.eq(StringUtils.isNotBlank(entryDate),"entry_date",entryDate);
        staffQuarter.eq(StringUtils.isNotBlank(staffType),"staff_type",staffType);
        if ("1".equals(serve)) {//1 查在职人员；其他查 全部
            ArrayList<Object> justTypeArr = new ArrayList<>();
            justTypeArr.add(0);
            justTypeArr.add(1);
            staffQuarter.in("just_type",justTypeArr);
        } else {
            if (justType.length > 0) {
                staffQuarter.in("just_type", justType);
            }
        }
        if (yearPart != null || quarterNum != null) {
            String stationSql = "";
            if (yearPart != null) {
                stationSql += " and year_part = " + yearPart;
            }
            if (quarterNum != null) {
                stationSql += " and quarter_num = " + quarterNum;
            }
            staffQuarter.inSql("id", "select staff_id from staff_station_change where staff_id = staff.id "+stationSql);
        }
        staffQuarter.eq(StringUtils.isNotBlank(quarterNum),"quarter_num",quarterNum);

        staffQuarter.like(StringUtils.isNotBlank(name),"name",name);

        if (statusArr.length > 0) {
            staffQuarter.in("status", statusArr);
        }

        if(StringUtils.isNotBlank(schoolId)){
            staffQuarter.eq("school_id",schoolId);
        }else{
            staffQuarter.in("school_id",this.baseSchoolIdList);
        }

        staffQuarter.orderByDesc("updated_at");
        iStaffService.page(page,staffQuarter);
        if (!page.getRecords().isEmpty()) {
            for (Staff staff : page.getRecords()) {
                String staffTypeName = iDictService.getDictNameByNumAndType(staff.getStaffType(), 25);
                staff.setStaffTypeName(staffTypeName);
                String schoolName = iOrganizationService.getSchoolName(staff.getSchoolId());
                staff.setSchoolName(schoolName);
                if (staff.getStationId() != null) {
                    String stationName = iStationService.getStationNameForId(staff.getStationId());
                    staff.setStationName(stationName);
                }
                //管理员信息
                if (staff.getAdminId() != null) {
                    Admin adminServiceById = iAdminService.getById(staff.getAdminId());
                    if (adminServiceById != null) {
                        adminServiceById.setPwd(null);
                        adminServiceById.setPwdShow(null);
                        //角色列表
                        QueryWrapper<RoleAdmin> roleAdminQueryWrapper = new QueryWrapper<>();
                        roleAdminQueryWrapper.eq("admin_id", staff.getAdminId());
                        List<RoleAdmin> roleAdminList = iRoleAdminService.list(roleAdminQueryWrapper);
                        ArrayList<Long> roleAdminArr = new ArrayList<>();
                        if (roleAdminList != null && !roleAdminList.isEmpty()) {
                            for (RoleAdmin roleAdmin : roleAdminList) {
                                roleAdminArr.add(roleAdmin.getRoleId());
                            }
                        }
                        adminServiceById.setRoleIdList(roleAdminArr);
                        staff.setAdminObj(adminServiceById);
                    }
                }
                //校区
                QueryWrapper<OrganizationStaff> organizationStaffQueryWrapper = new QueryWrapper<>();
                organizationStaffQueryWrapper.eq("staff_id", staff.getId());
                List<OrganizationStaff> organizationStaffList = iOrganizationStaffService.list(organizationStaffQueryWrapper);
                ArrayList<Long> organizationStaffIdList = new ArrayList<>();
                if (organizationStaffList != null && !organizationStaffList.isEmpty()) {
                    for (OrganizationStaff organizationStaff : organizationStaffList) {
                        organizationStaffIdList.add(organizationStaff.getOrganizationId());
                    }
                }
                staff.setScopeSchoolIdList(organizationStaffIdList);
                //入职信息
                QueryWrapper<StaffStatusChange> staffStatusChangeQueryWrapper = new QueryWrapper<>();
                staffStatusChangeQueryWrapper.eq("staff_id", staff.getId());
                staffStatusChangeQueryWrapper.orderByDesc("created_at");
                staffStatusChangeQueryWrapper.last("LIMIT 1");
                StaffStatusChange iStaffStatusChangeServiceOne = iStaffStatusChangeService.getOne(staffStatusChangeQueryWrapper);
                staff.setStatusChange(iStaffStatusChangeServiceOne);
                //离职信息，状态信息
                QueryWrapper<StaffStationChange> staffStationChangeQueryWrapper = new QueryWrapper<>();
                staffStationChangeQueryWrapper.eq("staff_id", staff.getId());
                staffStationChangeQueryWrapper.orderByDesc("created_at");
                staffStationChangeQueryWrapper.last("LIMIT 1");
                StaffStationChange iStaffStationChangeServiceOne = iStaffStationChangeService.getOne(staffStationChangeQueryWrapper);
                staff.setStaffStationChange(iStaffStationChangeServiceOne);
            }
        }


        return new Result(Code.OK,new PageResult(page.getRecords(), page.getTotal(), page.getPages()),"");
    }

    @PostMapping("/updateStatus")
    @ApiOperation("入职-确认试岗、取消入职")
    public Result updateStatus(@RequestBody StaffStatusChange staffStatusChangeBody){
        Quarter quarterNow = iQuarterService.getNowQuarter();
        Staff staffInfo = iStaffService.getById(staffStatusChangeBody.getStaffId());
        if (staffInfo == null){
            return new Result(Code.ERROR,"","员工不存在");
        }
        if (staffStatusChangeBody.getStatus().equals(StatusStaffEnum.TRY) || staffStatusChangeBody.getStatus().equals(StatusStaffEnum.IN) || staffStatusChangeBody.getStatus().equals(StatusStaffEnum.NOIN)) {
            staffInfo.setStatus(staffStatusChangeBody.getStatus());
        }
        StaffStatusChange staffStatusChange = new StaffStatusChange();
        staffStatusChange.setStaffId(staffStatusChangeBody.getStaffId());
        staffStatusChange.setStatus(staffStatusChangeBody.getStatus());
        staffStatusChange.setRemark("");
        if (quarterNow != null && (quarterNow.getYearPart() != null || quarterNow.getNum() != null)) {
            if (quarterNow.getYearPart() != null) {
                staffStatusChange.setYearPart(quarterNow.getYearPart());
            }
            if (quarterNow.getNum() != null) {
                staffStatusChange.setQuarterNum(quarterNow.getNum());
            }
        }
        if (staffStatusChangeBody.getStatus().equals(StatusStaffEnum.TRY)){
            iStaffStatusChangeService.save(staffStatusChange);
        }else if (staffStatusChangeBody.getStatus().equals(StatusStaffEnum.IN)){
            iStaffStatusChangeService.save(staffStatusChange);
        }else if (staffStatusChangeBody.getStatus().equals(StatusStaffEnum.NOIN)){
            staffStatusChange.setCauseId(staffStatusChangeBody.getCauseId());
            staffStatusChange.setCauseContent(staffStatusChangeBody.getCauseContent());
            iStaffStatusChangeService.save(staffStatusChange);
        }

        iStaffService.updateById(staffInfo);
        return new Result(Code.OK,"","成功");
    }

    /**
     * 确认入职
     * @param staff
     * @return
     */
    @PostMapping("/affirmEntry")
    @ApiOperation("入职-确认入职")
    @Transactional
    public Result affirmEntry(@RequestBody Staff staff){

        Quarter quarterNow = iQuarterService.getNowQuarter();
        Staff staffInfo = iStaffService.getById(staff.getId());
        if (staffInfo == null){
            return new Result(Code.ERROR,"","员工不存在");
        }
        StaffStatusChange staffStatusChange = new StaffStatusChange();
        staffStatusChange.setStaffId(staffInfo.getId());
        staffStatusChange.setStatus(StatusStaffEnum.IN);
        staffStatusChange.setRemark("");
        if (quarterNow != null && (quarterNow.getYearPart() != null || quarterNow.getNum() != null)) {
            if (quarterNow.getYearPart() != null) {
                staffStatusChange.setYearPart(quarterNow.getYearPart());
            }
            if (quarterNow.getNum() != null) {
                staffStatusChange.setQuarterNum(quarterNow.getNum());
            }
        }
        iStaffStatusChangeService.save(staffStatusChange);
        staff.setStatus(StatusStaffEnum.IN);
        iStaffService.updateTo(staff);
        return new Result(Code.OK,"","成功");
    }




    /**
     * 转正变动
     * @param staffStatusChangeBody
     * @return
     */
    @PostMapping("/justTypeChange")
    @ApiOperation("转正-转正变动")
    public Result justTypeChange(@RequestBody StaffStatusChange staffStatusChangeBody){
        Quarter quarterNow = iQuarterService.getNowQuarter();
        Staff staffInfo = iStaffService.getById(staffStatusChangeBody.getStaffId());
        if (staffInfo == null){
            return new Result(Code.ERROR,"","");
        }
        //0待转正，1已转正，2转正失败
        if (staffStatusChangeBody.getJustType().equals(1)){
            staffInfo.setJustType(staffStatusChangeBody.getJustType());

            StaffStatusChange staffStatusChange = new StaffStatusChange();
            staffStatusChange.setStaffId(staffStatusChangeBody.getStaffId());
            staffStatusChange.setJustType(staffStatusChangeBody.getJustType());

            staffStatusChange.setStatus(staffInfo.getStatus());
            staffStatusChange.setRemark("转正成功");
            if (quarterNow != null && (quarterNow.getYearPart() != null || quarterNow.getNum() != null)) {
                if (quarterNow.getYearPart() != null) {
                    staffStatusChange.setYearPart(quarterNow.getYearPart());
                }
                if (quarterNow.getNum() != null) {
                    staffStatusChange.setQuarterNum(quarterNow.getNum());
                }
            }
            iStaffStatusChangeService.save(staffStatusChange);
        } else if (staffStatusChangeBody.getJustType().equals(2)){
            staffInfo.setJustType(staffStatusChangeBody.getJustType());

            StaffStatusChange staffStatusChange = new StaffStatusChange();
            staffStatusChange.setStaffId(staffStatusChangeBody.getStaffId());
            staffStatusChange.setJustType(staffStatusChangeBody.getJustType());

            staffStatusChange.setStatus(staffInfo.getStatus());
            staffStatusChange.setRemark("转正失败");
            if (quarterNow != null && (quarterNow.getYearPart() != null || quarterNow.getNum() != null)) {
                if (quarterNow.getYearPart() != null) {
                    staffStatusChange.setYearPart(quarterNow.getYearPart());
                }
                if (quarterNow.getNum() != null) {
                    staffStatusChange.setQuarterNum(quarterNow.getNum());
                }
            }
            staffStatusChange.setCauseContent(staffStatusChangeBody.getCauseContent());
            staffStatusChange.setCauseId(staffStatusChangeBody.getCauseId());
            iStaffStatusChangeService.save(staffStatusChange);
        }

        iStaffService.updateById(staffInfo);
        return new Result(Code.OK,"","成功");
    }


    /**
     * 岗位调动
     * @param personManage
     * @return
     */
    @PostMapping("/staffStationChange")
    @ApiOperation("调动-调动保存")
    public Result stationChange(@RequestBody PersonManage personManage){
        return iStaffStationChangeService.stationChange(personManage);
    }

    /**
     * 离职
     * @param personManage
     * @return
     */
    @PostMapping("/staffStationLeave")
    @ApiOperation("离职-离职处理")
    public Result staffStationLeave(@RequestBody PersonManage personManage){
        return iStaffStationChangeService.staffStationLeave(personManage);
    }

    @GetMapping("/getOrganiztionAndStaffList")
    @ApiOperation("弹窗-获取校区/部门+员工")
    public Result getOrganiztionAndStaffList(@RequestParam(value = "schoolName",required = false) String schoolName,
                                             @RequestParam(value = "staffName",required = false) String staffName,
                                             @RequestParam(value = "status",required = false) Integer status,
                                             @RequestParam(value ="type",required = false) Integer type,
                                             @RequestParam(value ="staffStatus",required = false,defaultValue = "") String staffStatus,
                                             @RequestParam(value ="staffType",required = false,defaultValue = "") String staffType,
                                             @RequestParam(value ="staffJustType",required = false,defaultValue = "") String staffJustType){
        List<ResDepartment> resDepartmentList = iOrganizationService.getOrganiztionAndStaffList(schoolName,staffName,status,type,staffStatus,staffType,staffJustType);
        if (!resDepartmentList.isEmpty()) {
            for (ResDepartment resDepartment : resDepartmentList) {
                for (Staff staff: resDepartment.getStaffList()) {
                    String staffTypeName = iDictService.getDictNameByNumAndType(staff.getStaffType(), 25);
                    staff.setStaffTypeName(staffTypeName);
                    staff.setSchoolName(schoolName);
                    if (staff.getStationId() != null) {
                        String stationName = iStationService.getStationNameForId(staff.getStationId());
                        staff.setStationName(stationName);
                    }
                    //管理员信息
                    if (staff.getAdminId() != null) {
                        Admin adminServiceById = iAdminService.getById(staff.getAdminId());
                        if (adminServiceById != null) {
                            adminServiceById.setPwd(null);
                            adminServiceById.setPwdShow(null);
                            //角色列表
                            QueryWrapper<RoleAdmin> roleAdminQueryWrapper = new QueryWrapper<>();
                            roleAdminQueryWrapper.eq("admin_id", staff.getAdminId());
                            List<RoleAdmin> roleAdminList = iRoleAdminService.list(roleAdminQueryWrapper);
                            ArrayList<Long> roleAdminArr = new ArrayList<>();
                            if (roleAdminList != null && !roleAdminList.isEmpty()) {
                                for (RoleAdmin roleAdmin : roleAdminList) {
                                    roleAdminArr.add(roleAdmin.getRoleId());
                                }
                            }
                            adminServiceById.setRoleIdList(roleAdminArr);
                            staff.setAdminObj(adminServiceById);
                        }
                    }
                    //校区
                    QueryWrapper<OrganizationStaff> organizationStaffQueryWrapper = new QueryWrapper<>();
                    organizationStaffQueryWrapper.eq("staff_id", staff.getId());
                    List<OrganizationStaff> organizationStaffList = iOrganizationStaffService.list(organizationStaffQueryWrapper);
                    ArrayList<Long> organizationStaffIdList = new ArrayList<>();
                    if (organizationStaffList != null && !organizationStaffList.isEmpty()) {
                        for (OrganizationStaff organizationStaff : organizationStaffList) {
                            organizationStaffIdList.add(organizationStaff.getOrganizationId());
                        }
                    }
                    staff.setScopeSchoolIdList(organizationStaffIdList);
                    //入职信息
                    QueryWrapper<StaffStatusChange> staffStatusChangeQueryWrapper = new QueryWrapper<>();
                    staffStatusChangeQueryWrapper.eq("staff_id", staff.getId());
                    staffStatusChangeQueryWrapper.orderByDesc("created_at");
                    staffStatusChangeQueryWrapper.last("LIMIT 1");
                    StaffStatusChange iStaffStatusChangeServiceOne = iStaffStatusChangeService.getOne(staffStatusChangeQueryWrapper);
                    staff.setStatusChange(iStaffStatusChangeServiceOne);
                    //离职信息，状态信息
                    QueryWrapper<StaffStationChange> staffStationChangeQueryWrapper = new QueryWrapper<>();
                    staffStationChangeQueryWrapper.eq("staff_id", staff.getId());
                    staffStationChangeQueryWrapper.orderByDesc("created_at");
                    staffStationChangeQueryWrapper.last("LIMIT 1");
                    StaffStationChange iStaffStationChangeServiceOne = iStaffStationChangeService.getOne(staffStationChangeQueryWrapper);
                    staff.setStaffStationChange(iStaffStationChangeServiceOne);
                }
            }
        }
        return new Result(Code.OK,new PageResult<>(resDepartmentList, (long)resDepartmentList.size(), 1L),"");
    }

    @GetMapping("/findStaffList")
    @ApiOperation("弹窗-获取员工列表")
    public Result findStaffList(@RequestParam Map reMap,
                          @RequestParam(required = false) String[] schoolIdList,
                          @RequestParam(required = false) String[] statusArr,
                          @RequestParam(required = false) String justType
    ) {
        Integer pageNum = StringUtils.isEmpty((String) reMap.get("pageNum")) ? 1 : Integer.valueOf((String) reMap.get("pageNum"));
        Integer pageSize = StringUtils.isEmpty((String) reMap.get("pageSize")) ? 10 : Integer.valueOf((String) reMap.get("pageSize"));

        IPage<Staff> page = new Page<>(pageNum, pageSize);
        String isTeacher = (String) reMap.get("isTeacher");//是否上课老师
        String roleId = (String) reMap.get("roleId");//角色
        String name = (String) reMap.get("name");

        QueryWrapper<Staff> staffQueryWrapper = new QueryWrapper<>();

        staffQueryWrapper.eq(StringUtils.isNotBlank(isTeacher), "is_teacher", isTeacher);

        if (statusArr.length>0){
            staffQueryWrapper.in("status", statusArr);
        }
        staffQueryWrapper.eq(StringUtils.isNotBlank(justType), "just_type", justType);

        if (schoolIdList != null && schoolIdList.length>0) {
            String schoolIdStr = "";
            schoolIdStr = org.apache.tomcat.util.buf.StringUtils.join(schoolIdList);
            staffQueryWrapper.inSql("admin_id", "select for_id from appoint_school where  type =2 and school_id in (" + schoolIdStr + ")");
        }else {
            staffQueryWrapper.in("school_id",this.baseSchoolIdList);
        }

        if (StringUtils.isNotBlank(roleId)) {
            staffQueryWrapper.inSql("id", "select admin_id from role_admin where role_id = " + roleId);
        }

        if (StringUtils.isNotBlank(name)) {
            staffQueryWrapper.like("name", name);
        }
        iStaffService.findAll(page, staffQueryWrapper);
        return new Result(Code.OK, new PageResult(page.getRecords(), page.getTotal(), page.getPages()));
    }

    /**
     * 获取调动列表
     * @param yearPart
     * @param quarterNum
     * @param pageNum
     * @param pageSize
     * @param changeDate
     * @param name
     * @return
     */
    @GetMapping("/getStationChangeList")
    @ApiOperation("调动-获取调动列表")
    public Result getStationChangeList(@RequestParam(value = "yearPart",required = false) String yearPart,
                                       @RequestParam(value = "quarterNum",required = false) String quarterNum,
                                       @RequestParam(value = "schoolId",required = false) String schoolId,
                                       @RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
                                       @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize,
                                       @RequestParam(value = "changeDate",required = false) String changeDate,
                                       @RequestParam(value = "name",required = false) String name){
        IPage<StaffStationChange> iPage = new Page<>(pageNum,pageSize);

        QueryWrapper<StaffStationChange> staffStationChangeQueryWrapper = new QueryWrapper<>();
        staffStationChangeQueryWrapper.eq(StringUtils.isNotBlank(yearPart),"year_part",yearPart);
        staffStationChangeQueryWrapper.eq(StringUtils.isNotBlank(quarterNum),"quarter_num",quarterNum);
        staffStationChangeQueryWrapper.eq(StringUtils.isNotBlank(changeDate),"change_date",changeDate);
        staffStationChangeQueryWrapper.like(StringUtils.isNotBlank(name),"name",name);

        if(StringUtils.isNotBlank(schoolId) && !schoolId.isEmpty()){
            staffStationChangeQueryWrapper.eq("school_id",schoolId);
        }else{
            staffStationChangeQueryWrapper.in("school_id",this.baseSchoolIdList);
        }
        staffStationChangeQueryWrapper.orderByDesc("staff_id,created_at");
        iStaffStationChangeService.getTransferList(iPage,staffStationChangeQueryWrapper);
        return new Result(Code.OK, new PageResult<>(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }

    @GetMapping("/formal")
    @ApiOperation("转正-明天到期转正的有")
    public Result formal(@RequestParam Map reMap) {
        int pageNum = StringUtils.isEmpty((CharSequence) reMap.get("pageNum")) ? 1 : Integer.parseInt((String) reMap.get("pageNum"));
        int pageSize = StringUtils.isEmpty((CharSequence) reMap.get("pageSize")) ? 10 : Integer.parseInt((String) reMap.get("pageSize"));
        IPage<Staff> iPage = new Page<>(pageNum, pageSize);
        QueryWrapper<Staff> staffQueryWrapper = new QueryWrapper<>();
        LocalDate tomorrow = LocalDate.now().plusDays(1);
        staffQueryWrapper.eq("just_date",tomorrow);
        iStaffService.page(iPage, staffQueryWrapper);
        return new Result(Code.OK, new PageResult<>(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }

}
